package cn;

import cn.webrx.config.AppConfig;
import cn.webrx.config.DruidConfig;
import cn.webrx.entity.Student;
import cn.webrx.entity.Teacher;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Arrays;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfig.class, DruidConfig.class})
public class MyDemo {
    @Autowired
    private Teacher t1;


    @Autowired
    private Teacher t4;

    @Autowired
    private ApplicationContext ctx;

    @Autowired
    private Student student;

    @Test
    public void t3(){
        //System.out.println(student);
        //System.out.println(student.getArrint());
        //System.out.println(student.getArrstr()[3]);
        //System.out.println(student.getList().get(0));
        //System.out.println(student.getMap().get("name"));
        //System.out.println(student.getTeachers()[1]);
        System.out.println(student.getListts().get(1));
    }


    @Test
    public void t2(){
        System.out.println(t4.getBooks().length);
        System.out.println(t4.getBooks()[1]);
        System.out.println(t4.getUser());
    }


    @Test
    public void t1() {
        System.out.println(t1);
        System.out.println(ctx.getBeanDefinitionNames().length);
        System.out.println("--------------------");
        Arrays.stream(ctx.getBeanDefinitionNames()).forEach(System.out::println);

        var tt1 = ctx.getBean("t2");
        var tt2 = ctx.getBean("t2");
        System.out.println(tt1 == tt2);

    }
}
